﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Csla.Rules;

namespace Authorization
{
    public class StopProcessing : AuthorizationBase
    {
        public StopProcessing(Csla.Core.IPropertyInfo PrimaryProperty, int Priority, string AuthorizationMessage)
            : base(PrimaryProperty, Priority, AuthorizationMessage)
        {
            InputProperties = new List<Csla.Core.IPropertyInfo> { PrimaryProperty };
        }

        protected override void Execute(Csla.Rules.RuleContext context)
        {
            var obj = (Csla.Core.BusinessBase)context.Target;
            if (obj.BrokenRulesCollection.Where(c => c.Property == PrimaryProperty.Name).Count() > 0)
                context.AddInformationResult(null, true);
        }
    }
}
